<template>
  <div class="home-page">
    <div class="banner">
      <img src="https://dummyimage.com/800x150/cccccc/000000&text=Banner" alt="Banner" />
    </div>
    
    <div class="category-icons">
      <div class="category-item" v-for="(category, index) in categories" :key="index">
        <img :src="category.image" :alt="category.name" class="icon" />
        <div class="category-name">{{ category.name }}</div>
      </div>
    </div>
    
    <div class="product-section">
      <h3 class="section-title">热门商品</h3>
      <div class="product-list">
        <div class="product-card" v-for="(product, index) in products" :key="index">
          <div class="product-image">
            <img :src="product.image" :alt="product.name" />
          </div>
          <div class="product-info">
            <div class="product-name">{{ product.name }}</div>
            <div class="product-price">¥{{ product.price }}</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue';

// mock 分类数据
const categories = ref([
  { name: '家具', image: 'https://dummyimage.com/40x40/6ab7ff/fff&text=家' },
  { name: '服装', image: 'https://dummyimage.com/40x40/ff7878/fff&text=服' },
  { name: '电器', image: 'https://dummyimage.com/40x40/71da71/fff&text=电' },
  { name: '食品', image: 'https://dummyimage.com/40x40/ffcf5c/fff&text=食' },
  { name: '美妆', image: 'https://dummyimage.com/40x40/d59bf6/fff&text=美' }
]);

// mock 商品数据
const products = ref([
  { name: '时尚连衣裙', price: '199.00', image: 'https://dummyimage.com/100x100/cccccc/000000&text=连衣裙' },
  { name: '休闲男装T恤', price: '99.00', image: 'https://dummyimage.com/100x100/cccccc/000000&text=T恤' },
  { name: '舒适靠垫', price: '59.00', image: 'https://dummyimage.com/100x100/cccccc/000000&text=靠垫' },
  { name: '智能手表', price: '599.00', image: 'https://dummyimage.com/100x100/cccccc/000000&text=手表' }
]);
</script>

<style scoped>
.home-page {
  padding-bottom: 60px;
}

.banner {
  width: 100%;
  height: 150px;
  background-color: #f5f5f5;
  margin-bottom: 15px;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.banner img {
  width: 100%;
  height: auto;
  object-fit: cover;
}

.category-icons {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-around;
  padding: 10px 0;
  background-color: #fff;
  margin-bottom: 10px;
}

.category-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 20%;
  padding: 8px 0;
}

.icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  margin-bottom: 5px;
  background-color: #f0f0f0;
}

.category-name {
  font-size: 12px;
  color: #333;
}

.section-title {
  font-size: 16px;
  font-weight: bold;
  padding: 10px;
  margin: 0;
  background-color: #fff;
  border-bottom: 1px solid #eee;
}

.product-section {
  background-color: #fff;
}

.product-list {
  display: flex;
  flex-wrap: wrap;
  padding: 5px;
}

.product-card {
  width: 50%;
  padding: 5px;
  box-sizing: border-box;
}

.product-image {
  width: 100%;
  height: 150px;
  background-color: #f5f5f5;
  margin-bottom: 8px;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.product-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-info {
  padding: 0 5px;
}

.product-name {
  font-size: 14px;
  color: #333;
  margin-bottom: 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-price {
  font-size: 16px;
  color: #ff6b35;
  font-weight: bold;
}
</style> 